package com.yn.common.response.zy;


import cn.hutool.core.bean.BeanUtil;
import com.yn.common.enums.AppointmentStatusEnum;
import com.yn.common.enums.BusinessTypeEnum;
import com.yn.common.enums.GenderEnum;
import com.yn.common.model.zy.SubscribeInfoDO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="机构床位预约分页返回对象", description="机构床位预约分页对象")
public class InstPageInfoResponse {

    @ApiModelProperty(value = "预约id")
    private Integer id;

    @ApiModelProperty(value = "关联id")
    private Integer businessId;

    @ApiModelProperty(value = "机构名称 ")
    private String organName;

    @ApiModelProperty(value = "机构类型 ")
    private String organType;

    //业务类型(0:普通预约 1:急诊预约 2:机构预约)
    @ApiModelProperty(value = "业务类型")
    private Integer businessType;

    //业务类型(0:普通预约 1:急诊预约 2:机构预约)
    @ApiModelProperty(value = "业务类型字符串")
    private String businessTypeStr;

    @ApiModelProperty(value = "患者姓名", required = true, example = "张三")
    private String userOrderName;

    @ApiModelProperty(value = "家属/联系人电话", required = true, example = "13800138000")
    private String userOrderPhone;

    @ApiModelProperty(value = "患者年龄", example = "65")
    private Integer age;

    @ApiModelProperty(value = "性别")
    private Integer gender;

    @ApiModelProperty(value = "性别字符串")
    private String genderStr;

    @ApiModelProperty(value = "状态")
    private Integer status;

    @ApiModelProperty(value = "状态字符串")
    private String statusStr;

    @NotNull(message = "预计出院时间不能为空")
    @ApiModelProperty(value = "预计出院日期", required = true, example = "2025-08-15")
    private String estDischargeTime;

    public static InstPageInfoResponse transform(SubscribeInfoDO infoDO){
        InstPageInfoResponse response = new InstPageInfoResponse();
        BeanUtil.copyProperties(infoDO, response);
        if(infoDO.getGender() != null){
            response.setGenderStr(GenderEnum.getByCode(infoDO.getGender()).getName());
        }
        response.setBusinessTypeStr(BusinessTypeEnum.getByCode(infoDO.getBusinessType()).getName());
        response.setStatusStr(AppointmentStatusEnum.getByCode(infoDO.getStatus()).getName());
        return response;
    }
}
